package com.example.personalcenter.util;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPrefUtil {

    private static final String PREF_NAME = "user";

    public static void saveEmail(Context context, String email) {
        SharedPreferences sp = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        sp.edit().putString("email", email).apply();
    }

    public static String getEmail(Context context) {
        SharedPreferences sp = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sp.getString("email", "");
    }

    public static void saveInterest(Context context, String interest) {
        SharedPreferences sp = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        sp.edit().putString("interest", interest).apply();
    }

    public static String getInterest(Context context) {
        SharedPreferences sp = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sp.getString("interest", "未选择");
    }

    public static void clear(Context context) {
        SharedPreferences sp = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        sp.edit().clear().apply();
    }
}